<template>
	<div class="user">
		<van-nav-bar title="我的" fixed />
		<div class="user-info">
			<div class="head-img">
				<img :src="userInfo.avatar||head" alt="">
			</div>
			<div class="info">
				<p class="name">{{userInfo.nickname}}</p>
				<span class="tips" v-if="userInfo.is_check == 1&&token!=null">已审核</span>
				<span class="tips" v-if="userInfo.is_check != 1&&token!=null">待审核站长</span>
				<span class="tips" v-if="token==null">未登录</span>
			</div>
		</div>
		<div class="list-group">
			<van-cell :title="l.text" :icon="l.icon" is-link v-for="(l,index) in list" :key="index" @click="isLogin(l)">

			</van-cell>
		</div>
		<p style="text-align: center;margin-top: 2rem;">
			<van-button type="primary" size="large" round color="rgba(254,118,0,1)" style="width: 80%;" @click="loginOut" v-if="token!=null">退出登录</van-button>
			<van-button type="primary" size="large" round color="rgba(254,118,0,1)" style="width: 80%;" @click="tologin" v-if="token==null">去登录</van-button>
		</p>
		
	</div>
</template>

<script>
	import head from "@/assets/img/head_img.png"
	import user_info from "@/assets/img/user_info.png"
	import release from "@/assets/img/release.png"
	import auth from "@/assets/img/auth.png"
	import safe from "@/assets/img/safe.png"
	import ask_icon from "@/assets/img/ask_icon.png"
	import article from "@/assets/img/article.png"
	import my_article from "@/assets/img/my_article.png"
	import look from "@/assets/img/look.png"
	import vote from "@/assets/img/vote.png"
	import event from "@/assets/img/event.png"
	import watch_icon from "@/assets/img/watch_icon.png"
	export default {
		name: "User",
		components: {

		},
		data() {
			return {
				head: head,
				userInfo:{avatar:''},
				token:null,
				list: [{
						icon: user_info,
						text: "个人资料",
						url: '/userinfo?title=个人资料'
					},
					{
						icon: release,
						text: "我的发布",
						url: ''
					},
					{
						icon: auth,
						text: "用户认证",
						url: '/safe?title=用户认证'
					},
					{
						icon: safe,
						text: "安全设置",
						url: '/safe?title=安全设置'
					},
					{
						icon: ask_icon,
						text: "卜咚问答",
						url: '/safe?title=卜咚问答'
					},
					{
						icon: article,
						text: "文章管理",
						url: '/articleList?title=文章'
					},
					{
						icon: my_article,
						text: "我的文章",
						url: '/safe?title=我的文章'
					},
					{
						icon: look,
						text: "浏览历史",
						url: ''
					},
					{
						icon: vote,
						text: "投票评议",
						url: '/safe?title=投票评议'
					},
					{
						icon: event,
						text: "事件评议",
						url: ''
					},
					{
						icon: watch_icon,
						text: "我的关注",
						url: ''
					}
				]
			}
		},
		mounted() {
			if(this.$getcookie("jy_token")){
				this.userInfo = JSON.parse(this.$getcookie("userInfo"))
				this.token = this.$getcookie("jy_token")
			}
			
		},
		methods:{
			isLogin(item){
				if(this.token == null){
					this.$toast.fail("请登录后操作！")
				}else{
					this.$router.push({
						path:item.url,
						query:{
							title:item.text
						}
					})
				}
			}
		}


	}
</script>

<style scoped lang="less">
	.user {
		padding-top: 46px;

		.user-info {
			background: #fff;
			height: 4.44rem;
			margin-top: 0.31rem;
			margin-bottom: 0.16rem;
			padding: 0.78rem;
			display: flex;
			align-items: center;
			justify-content: flex-start;

			.head-img {
				width: 2.91rem;
				height: 2.91rem;
				margin-right: 0.84rem;
				

				img {
					
					width: 2.91rem;
					height: 2.91rem;
					border-radius: 50%;
					object-fit: cover;
					
				}

			}

			.info {
				flex: 1;

				.name {
					font-size: 0.88rem;
					font-family: PingFang SC;
					font-weight: 500;
					color: rgba(34, 34, 34, 1);
				}

				.tips {
					background: rgba(255, 198, 147, 1);
					border-radius: 1rem;
					padding: 0.28rem 0.31rem;
					font-size: 0.63rem;
					font-family: PingFang SC;
					font-weight: 500;
					color: rgba(255, 255, 255, 1);
					display: inline-flex;
					justify-content: center;
					align-items: center;
				}
			}
		}

	}
</style>
<style lang="less">
	.user {
		.van-cell {
			padding: 1.28rem 1rem;
			font-size: 0.88rem;
			font-family: PingFang SC;
			font-weight: 500;
			color: rgba(31, 31, 31, 1);

			.van-cell__left-icon {
				margin-right: 1.03rem;
			}
		}

	}
</style>
